<?
if($userName){
?>
<CENTER>
<?
	if($statusMsg){echo $statusMsg; $statusMsg=""; }
	if($errorMsg){echo $errorMsg; $errorMsg=""; }
?>
<TABLE border=0>
	<TR>
			<TH colspan='2'><a href='<?$params[sid]=$sid;$params[action]="777";echo "$baseURL/$webDIR/?".encode_params($params);?>'>ADMIN PANEL</a></TH>
	</TR>
	<TR>
		<TD colspan='2'>
			<table border=1 width='100%'>
				<tr>
					<td>Username : </td><td><?echo $userName?></td>
				</tr>
				<tr>
					<td>Amount :  </td><td>$ <? echo check_user_credit($userName,"",""); ?></td>
				</tr>
				<tr>
					<td>Number of clients : </td><td><? echo get_packets_count($userName,'clients');?></td>
				</tr>
				<tr>
					<td>Available packets : </td><td><? echo get_packets_count($userName,'available');?></td>
				</tr>
				<tr>
					<td colspan='2'>
						<TABLE border='1' width='100%'>
							<TR>
								<?
									$params[sid]  = $sid;
									$params[action] = "change_state";
									$url="$baseURL/$webDIR/?".encode_params($params);
								?>
								<FORM action='<?=$url;?>' method='POST'>
									<TD>Reseller state : </TD>
									<TD>
										<select name='state'>
											<option value=''>-------</option>
											<?
												$state = get_reseller_state($userName);
												$opt = "
													<option value='A'>Active</option>
													<option value='B'>Blocked</option>
													<option value='S'>Suspended</option>
												";
												$newopt = str_replace("'$state'","$state selected",$opt);
												echo $newopt;
											?>
										</select>
									</TD>
									<TD><input type='submit' value='Change'></TD>
								</FORM>
							</TR>



							<TR>
								<?
									$params[sid]  = $sid;
									$params[action] = "set_amount";
									$url="$baseURL/$webDIR/?".encode_params($params);
								?>
								<FORM action='<?=$url;?>' method='POST'>
									<TD>Reseller amount : </TD>
									<TD>
										<select name='type'>
													<option value='+'>+</option>
													<option value='-'>-</option>
										</select>
										<input type='text' name='value' size='5'>
									</TD>
									<TD><input type='submit' value='Change'></TD>
								</FORM>
							</TR>

							<TR>
								<?
									$params[sid]  = $sid;
									$params[action] = "delete_packet";
									$url="$baseURL/$webDIR/?".encode_params($params);
								?>
								<FORM action='<?=$url;?>' method='POST'>
									<TD>Delete packet : </TD>
									<TD>
										<select name='packet'>
											<option value=''>---------</option>
											<?
												echo list_available_packets($userName,"select_remote");

											?>
										</select>
									</TD>
									<TD><input type='submit' value='Delete'></TD>
								</FORM>
							</TR>
						</TABLE>
					</td>
				</tr>
			</table>
		</TD>
	</TR>
	<TR>
		<TD valign='top'>
			<table border=1 width='100%'>
				<tr>
					<td><a href='<?$params[sid]=$sid;$params[action]="add_packet";echo "$baseURL/$webDIR/?".encode_params($params);?>'> Add packet </a></td>
				</tr>
				<tr>
					<td><a href='<?$params[sid]=$sid;$params[action]="activate_packet";echo "$baseURL/$webDIR/?".encode_params($params);?>'> Activate packet </a></td>
				</tr>
				<tr>
					<td><a href='<?$params[sid]=$sid;$params[action]="view_clients";echo "$baseURL/$webDIR/?".encode_params($params);?>'> View clients</a></td>
				</tr>
				<tr>
					<td><a href='<?$params[sid]=$sid;$params[action]="change_details";echo "$baseURL/$webDIR/?".encode_params($params);?>'>Change details</a></td>
				</tr>
				<tr>
					<td><a href='<?$params[sid]=$sid;$params[action]="deposit";echo "$baseURL/$webDIR/?".encode_params($params);?>'>Deposit</a></td>
				</tr>
				<tr>
					<td><a href='<?$params[sid]=$sid;$params[action]="history";echo "$baseURL/$webDIR/?".encode_params($params);?>'>History</a></td>
				</tr>

			</table>
		</TD>
		<TD valign='top'>
			<table border=1 width='100%'>
				<tr>
					<th colspan='3'>Packets : </th>
				</tr>
				<tr>
					<td>Name</td>
					<td>Activated</td>
					<td>Available</td>
				</tr>
				<? echo list_all_packets($userName); ?>
			</table>
		</TD>
	</TR>
</TABLE>
</CENTER>
<?
} //END IF($userName)
else include("search.html");
?>
